/*
 * Copyright (c) 2018-2999 九五云信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.distribution.platform.controller;

import com.yami.shop.common.config.Constant;
import com.yami.shop.distribution.comment.model.DistributionLevel;
import com.yami.shop.distribution.comment.model.DistributionLevelSet;
import com.yami.shop.distribution.comment.service.DistributionLevelSetService;
import com.yami.shop.security.platform.model.YamiSysUser;
import com.yami.shop.security.platform.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lgh on 2019/04/04.
 */
@RestController
@RequestMapping("/distribution/distributionLevel")
@AllArgsConstructor
public class DistributionLevelController {

    private DistributionLevelSetService distributionLevelSetService;

    /**
     * 获取信息
     */
    @GetMapping("/info")
    @PreAuthorize("@pms.hasPermission('distribution:distributionLevel:info')")
    public ResponseEntity<List<DistributionLevel>> info() {
        YamiSysUser sysUser = SecurityUtils.getSysUser();
        DistributionLevelSet distributionLevelSet = distributionLevelSetService.getByShopId();
        return ResponseEntity.ok(distributionLevelSet.getDistributionLevels());
    }

//    /**
//     * 分页获取
//     */
//    @GetMapping("/page")
//    @PreAuthorize("@pms.hasPermission('admin:distributionLevel:page')")
//    public ResponseEntity<IPage<DistributionLevel>> page(DistributionLevel distributionLevel, PageParam<DistributionLevel> page) {
//        IPage<DistributionLevel> list = distributionLevelService.page(page, new LambdaQueryWrapper<DistributionLevel>());
//        return ResponseEntity.ok(list);
//    }

//    /**
//     * 获取信息
//     */
//    @GetMapping("/info/{id}")
//    //@PreAuthorize("@pms.hasPermission('admin:distributionLevel:info')")
//    public ResponseEntity<DistributionLevel> info(@PathVariable("id") Long id) {
//        DistributionLevel distributionLevel = distributionLevelService.getById(id);
//        return ResponseEntity.ok(distributionLevel);
//    }
//
//    /**
//     * 保存
//     */
//    @PostMapping
//    //@PreAuthorize("@pms.hasPermission('admin:distributionLevel:save')")
//    public ResponseEntity<Void> save(@RequestBody @Valid DistributionLevel distributionLevel) {
//        distributionLevelService.save(distributionLevel);
//        return ResponseEntity.ok().build();
//    }
//
//    /**
//     * 修改
//     */
//    @PutMapping
//    //@PreAuthorize("@pms.hasPermission('admin:distributionLevel:update')")
//    public ResponseEntity<Void> update(@RequestBody @Valid DistributionLevel distributionLevel) {
//        distributionLevelService.updateById(distributionLevel);
//        return ResponseEntity.ok().build();
//    }
//
//    /**
//     * 删除
//     */
//    @DeleteMapping("/{id}")
//    //@PreAuthorize("@pms.hasPermission('admin:distributionLevel:delete')")
//    public ResponseEntity<Void> delete(@PathVariable Long id) {
//        distributionLevelService.removeById(id);
//        return ResponseEntity.ok().build();
//    }
}
